include("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js");
include("js/utils.js");
include("js/hapiHelper.js");

var siteBase = location.href.match(/http:\/\/[^\/]*\//)[0];

var oldOnload
if( window.onload ) {
	oldOnload = window.onload;
}

window.onload=function() {
    $.ajaxSettings.beforeSend=function(xhr){
        xhr.setRequestHeader('X-Requested-With', {toString: function(){ return ''; }});
    };
	
	if( typeof oldOnload == 'function' ) oldOnload();	
	
	var locString = window.location.toString();
	
	var pages = {
		GlobalInfil : locString.match(/\/servlet\/Planetinf\?globalmgr=&planetid=/),
		Infil : locString.match(/\/servlet\/Planetinf(\?planetid=[0-9]+)?(&lmt=[0-9]+)?$/) && $('select[name=planetid]').length,
		NewInfil : locString.match(/\/servlet\/Planetinf$/) && $('select[name=infplanetid]').length,
		FleetDivide : locString.match(/\/servlet\/Floatorders$/) && $('select[name=nbtimes]').length,
		LocalFleet : locString.match(/\/servlet\/Floats(\?pagetype=local_fleets&lmt=[0-9]*)?$/),
		ForeignFleet :  locString.match(/\/servlet\/Floats\?pagetype=foreign_fleets/),
		Home : locString.match(/\/servlet\/Home/),
		Forums : locString.match(/\/servlet\/Forums/),
		Player : locString.match(/\/servlet\/Player/),
		PlanetFleet : $('input[name=updatecamouflage]').length
	}

	if( pages.Forums || pages.Player )
		include("js/btCalc.js");
	
	if( pages.GlobalInfil )
		include("js/globalInfil.js");
	
	if( pages.Infil )
		include("js/infil.js");

	if( pages.NewInfil )
		include("js/newInfil.js");
	
	if( pages.FleetDivide )
		include("js/fleetDivide.js");
	
	if( pages.LocalFleet || pages.ForeignFleet )
		include("js/fleetPages.js");

	if( pages.PlanetFleet )
		include("js/planetFleet.js");
}